<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 800px;
            margin: 50px auto;
        }
        .box>div{
            float: left;
        }
        #first-menu{
            width: 300px;
            height: 200px;
            background-color: blue;
            line-height: 200px;
            text-align: center;
            font-weight: 700;
        }
        #sec-menu{
            width: 200px;
            height: 100px;
            background-color: rgb(217, 80, 135);
            line-height: 100px;
            text-align: center;
            margin-left: 30px;
            font-weight: 700;
            display: none;
        }
    </style>
</head>
<body>
    <div class="box">
        <div id="first-menu">一级菜单</div>
        <div id="sec-menu">二级菜单</div>
    </div>
</body>
<script>
    var firstMenu=document.getElementById('first-menu');
    var secMenu=document.getElementById('sec-menu');
    firstMenu.onmouseover=secMenu.onmouseover=function(e1){
        //清除定时器
        clearTimeout(timeid);
        secMenu.style.display='block';
    }
    var timeid;
    firstMenu.onmouseout=secMenu.onmouseout=function(){
        timeid=setTimeout(function(){
            secMenu.style.display='none';
        },10);
    }
</script>
</html>